package com.dou.sample.opengl_project.shape;

import android.opengl.GLES20;

import com.dou.sample.opengl_project.data.VertexArray;
import com.dou.sample.opengl_project.shader.ShaderProgram;

/**
 * Created by Dou on 2018/1/19.
 */

public class Triangel extends Shape{

    private static final String A_POSITION = "a_Position";
    private static final String U_COLOR = "u_Color";

    private static final int POSITION_COUNT = 2;
    private static final int COLOR_COUNT = 3;

    int aPositionLocation;
    int aColorLocation;

    final float[] VERTEX_DATA = {
            0, -0.5f,
            -0.25f, 0.5f,
            0.25f, 0.5f
    };

    public Triangel(){
        vertexArray = new VertexArray(VERTEX_DATA);

    }

    @Override
    void bindData(ShaderProgram program) {
        vertexArray.setVertexAttributePointer(0, aPositionLocation, POSITION_COUNT, 0);
    }

    @Override
    void draw() {
        GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0 ,3);
    }
}
